﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using Model;

namespace NCRE学生考试端V1._0.教师端操作类
{
    public partial class frmAllSore : Form
    {
        public frmAllSore()
        {
            InitializeComponent();
        }
        #region 窗体单一显示 修改人：李金颖-添加备注-2018-12-8 12:11:29
        private static frmAllSore FrmallSore = null;

        public static frmAllSore GetInstance()
        {
            if (FrmallSore == null || FrmallSore.IsDisposed)
            {
                FrmallSore = new frmAllSore();
            }
            return FrmallSore;
        } 
        #endregion

        #region 实例化WindowsB层
        /// <summary>
        /// 实例化WindowsB层
        /// </summary>
        WinQuestionEntityBll WinContent = new WinQuestionEntityBll();


        #endregion

        #region 实例化WordB层
        /// <summary>
        /// 实例化WordB层
        /// </summary>
        WordQuestionEntityBll WordContent = new WordQuestionEntityBll();
        #endregion

        #region 实例化ExcelB层
        /// <summary>
        /// 实例化ExcelB层
        /// </summary>      
        ExcelEntityBll ExcelContent = new BLL.ExcelEntityBll();
        #endregion

        #region 实例化PPTB层
        /// <summary>
        /// 实例化PPTB层
        /// </summary>       
        PptQuestionEntityBLL PPTContent = new PptQuestionEntityBLL();
        #endregion

        #region 实例化IE实体与B层
        /// <summary>
        /// 实例化IE实体与B层
        /// </summary>        
        IeQuestionEntityBll IEContent = new IeQuestionEntityBll();
        #endregion

        #region 显示A~H的试卷类型——陈新月——2018-04-08
        /// <summary>
        /// 显示A~H的试卷类型——陈新月——2018-04-08
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmAllSore_Load(object sender, EventArgs e)
        {
            //显示试卷类型
            IeQuestionEntityBll IEPaperType = new IeQuestionEntityBll();
            DataTable dt = new DataTable();
            dt = IEPaperType.InqueryPaperType();
            if (dt.Rows.Count > 0)
            {
                cobPaperType.DataSource = dt;
                cobPaperType.DisplayMember = "试卷类型";
                cobPaperType.ValueMember = "paperType";
            }
            //窗体默认显示分数-苑仁杰-2018-12-22
            textBox1.Text = "100";            
            textBox2.Text = "20";

            //显示选择题题量
            DataTable dtSelect = new DataTable();
            SelectQuestionBll selectquestionbll = new BLL.SelectQuestionBll();
            dtSelect = selectquestionbll.QuerySelectQuestionSum();
            numericUpDown1.Value = decimal.Parse(dtSelect.Rows[0]["selectQuestionSum"].ToString());

            //默认显示A卷操作题
            GetWinSore();
            
            //调用查询Word方法
            GetWordSore();
            //调用查询Excel方法
            GetExcelSore();
            //调用查询PPT方法
            GetPPTSore();
            //调用查询IE方法
            GetIESore();

            //默认显示windows的页数
            //cRows = dtwin.Rows.Count;
            //cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
            //PageCurrent = 1;
            //LoadData(dtwin, dataGridView1);
            //dataGridView1.AllowUserToAddRows = false;

            #region 将查询出来的分值赋值到文本框中
            assignWin();
            assignWord();
            assignExcel();
            assignPPT();
            assignIE();
            #endregion
        }
        #endregion

        #region 当试卷类型的索引值发生变化时，根据试卷类型进行查询——陈新月——2018-04-18
        private void cobPaperType_SelectedIndexChanged(object sender, EventArgs e)
        {
            
            //调用查询Windows方法
            GetWinSore();
            //调用查询Word方法
            GetWordSore();
            //调用查询Excel方法
            GetExcelSore();
            //调用查询PPT方法
            GetPPTSore();
            //调用查询IE方法
            GetIESore();
            //将查询出来的分值赋值到文本框中
            assignWin();
            assignWord();
            assignExcel();
            assignPPT();
            assignIE();

        }
        #endregion

        #region 点击保存，将更改后的分数配置入库
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 窗体单一显示 修改人：苑仁杰-文本框为空判断-2018-12-8 12:11:29
            if (numericUpDown1.Value.ToString()!="" && numericUpDown1.Value!=0)
            {
                try
                {
                    int txtnum1;
                    int.TryParse(textBox1.Text, out txtnum1);
                    int txtnum2;
                    int.TryParse(textBox2.Text, out txtnum2);
                    int txtnum3;
                    int.TryParse(textBox3.Text, out txtnum3);
                    int txtnum4;
                    int.TryParse(textBox4.Text, out txtnum4);
                    int txtnum5;
                    int.TryParse(textBox5.Text, out txtnum5);
                    int txtnum6;
                    int.TryParse(textBox6.Text, out txtnum6);
                    int txtnum7;
                    int.TryParse(textBox7.Text, out txtnum7);
                    int sum = txtnum2 + txtnum3 + txtnum4 + txtnum5 + txtnum6 + txtnum7;
                    if (txtnum1 != sum)
                    {
                        label18.Visible = true;
                    }
                    if (numericUpDown1.Value == 0)
                    {
                        label18.Visible = true;
                        label18.Text = "选择题数量必须大于0！";
                    }
                    else
                    {
                        label18.Visible = false;
                        //调用更新选择题配置的方法：
                        UpdateSelectConfig();
                        //调用更新操作题的方法
                        UpdateWinSore();
                        //调用更新Word题的方法
                        UpdateWordSore();
                        //调用更新Excel题的方法
                        UpdateExcelSore();
                        //调用更新PPT题的方法
                        UpdatePPTSore();
                        //调用更新IE题的方法
                        UpdateIESore();
                        label18.Text = "分数配置成功！";
                        label18.Font = new Font("宋体", 18, FontStyle.Bold);
                        label18.ForeColor = Color.Red;
                        label18.Visible = true;
                    }

                }
                catch (Exception)
                {

                    label18.Text = "分数配置失败！";
                    label18.Font = new Font("宋体", 18, FontStyle.Bold);
                    label18.ForeColor = Color.Red;
                    label18.Visible = true;
                }
            }
            else
            {
                MessageBox.Show("配置选择题数量为空或0，请输入正确数量后再保存");
            }

            #endregion
        }
        #endregion

        #region 当修改操作题分数时，实时更新到文本框中——陈新月——2018-04-19
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            assignWin();
        }
        #endregion

        #region 当修改Word分数时，实时更新到文本框中——陈新月——2018-04-19
        private void dataGridView2_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {                               
            assignWord();
        }
        #endregion

        #region 当修改Excel分数时，实时更新到文本框中——陈新月——2018-04-19
        private void dataGridView3_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            assignExcel();
        }
        #endregion

        #region 当修改PPT题分数时，实时更新到文本框中——陈新月——2018-04-19
        private void dataGridView4_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            assignPPT();
        }
        #endregion

        #region 当修改IE题分数时，实时更新到文本框中——陈新月——2018-04-19
        private void dataGridView5_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            assignIE();
        }
        #endregion

        #region 限制文本框只能输入数字并且字符长度为3
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = true;
            if ((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == (char)8)
            {
                e.Handled = false;
            }
        }
        #endregion

        //#region 分页功能-吕德彪-2018.04.22
        ////定义分页需要的变量
        //int cRows = 0;
        //int RowCurrent = 0;
        //int cPages = 0;
        //int PageCurrent = 0;
        //const int PageSize = 10;
        //int PageIndex = 0;

        //private void LoadData(DataTable table,DataGridView dataGridView)
        //{
        //    if (PageCurrent == 1)
        //    {
        //        ts_PagePrevious.Enabled = false;
        //    }
        //    else
        //    {
        //        ts_PagePrevious.Enabled = true;
        //    }
        //    if (cPages == PageCurrent)
        //    {
        //        ts_PageNext.Enabled = false;
        //    }
        //    else
        //    {
        //        ts_PageNext.Enabled = true;
        //    }
        //    ts_PagePostion.Text = PageCurrent.ToString();
        //    ts_Pages.Text = cPages.ToString();
        //    int startRow = (PageCurrent - 1) * PageSize;
        //    int endRow;
        //    if (table.Rows.Count < PageSize)
        //    {
        //        endRow = table.Rows.Count;
        //    }
        //    else
        //    {
        //        endRow = PageCurrent == cPages ? cRows : PageCurrent * PageSize;
        //    }           
        //    DataTable dtTemp = table.Clone();
        //    if (table.Rows.Count != 0)
        //    {
        //        for (int i = startRow; i < endRow; i++)
        //        {
        //            dtTemp.ImportRow(table.Rows[i]);
        //        }
        //        #region 判断用哪个datasource接收
        //        if (table == dtwin)
        //        {
        //            bindingSource1.DataSource = dtTemp;
        //            dataGridView.DataSource = bindingSource1;
        //        }
        //        else if (table == dtword)
        //        {
        //            bindingSource2.DataSource = dtTemp;
        //            dataGridView.DataSource = bindingSource2;
        //        }
        //        else if (table == dtexcel)
        //        {
        //            bindingSource3.DataSource = dtTemp;
        //            dataGridView.DataSource = bindingSource3;
        //        }
        //        else if (table == dtPPT)
        //        {
        //            bindingSource4.DataSource = dtTemp;
        //            dataGridView.DataSource = bindingSource4;
        //        }
        //        else if(table == dtIE)
        //        {
        //            bindingSource6.DataSource = dtTemp;
        //            dataGridView.DataSource = bindingSource6;
        //        }
        //        #endregion
        //    }
        //}

        //#region tabpage切换事件
        //private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    switch (tabControl1.SelectedIndex)
        //    {
        //        case 0:
        //            cRows = dtwin.Rows.Count;
        //            cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
        //            PageCurrent = 1;
        //            LoadData(dtwin, dataGridView1);
        //            break;
        //        case 1:
        //            cRows = dtword.Rows.Count;
        //            cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
        //            PageCurrent = 1;
        //            LoadData(dtword, dataGridView2);
        //            break;
        //        case 2:
        //            cRows = dtexcel.Rows.Count;
        //            cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
        //            PageCurrent = 1;
        //            LoadData(dtexcel, dataGridView3);
        //            break;
        //        case 3:
        //            cRows = dtPPT.Rows.Count;
        //            cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
        //            PageCurrent = 1;
        //            LoadData(dtPPT, dataGridView4);
        //            break;
        //        case 4:
        //            cRows = dtIE.Rows.Count;
        //            cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
        //            PageCurrent = 1;
        //            LoadData(dtIE, dataGridView5);
        //            break;
        //    }
        //}
        //#endregion

        //#region 切换上一页下一页时，用于判断分页控件归属于哪个tabpage
        //private void SelectedIndexChanged()
        //{
        //    if (tabControl1.SelectedIndex == 0)
        //    {
        //        LoadData(dtwin, dataGridView1);
        //    }
        //    else if (tabControl1.SelectedIndex == 1)
        //    {
        //        LoadData(dtword, dataGridView2);
        //    }
        //    else if (tabControl1.SelectedIndex == 2)
        //    {
        //        LoadData(dtexcel, dataGridView3);
        //    }
        //    else if (tabControl1.SelectedIndex == 3)
        //    {
        //        LoadData(dtPPT, dataGridView4);
        //    }
        //    else if (tabControl1.SelectedIndex == 4)
        //    {
        //        LoadData(dtIE, dataGridView5);
        //    }            
        //}
        //#endregion

        //private void bindingNavigator1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        //{
        //    if (e.ClickedItem.Text == "上一页")
        //    {
        //        ts_PageNext.Enabled = true;
        //        if (PageCurrent == 1)
        //        {
        //            ts_PagePrevious.Enabled = false;
        //            MessageBox.Show("已经是第一页了");
        //            return;
        //        }
        //        PageCurrent--;
        //        SelectedIndexChanged();                
        //    }
        //    if (e.ClickedItem.Text == "下一页")
        //    {
        //        ts_PagePrevious.Enabled = true;
        //        if (PageCurrent == PageSize)
        //        {
        //            ts_PageNext.Enabled = false;
        //            MessageBox.Show("已经是最后一页了");
        //            return;
        //        }
        //        PageCurrent++;
        //        SelectedIndexChanged();
        //    }
        //}

        //private void bindingNavigatorMoveLastPage_Click(object sender, EventArgs e)
        //{
        //    PageCurrent = cPages;
        //    bindingNavigatorMoveFirstPage.Enabled = true;
        //    bindingNavigatorMoveLastPage.Enabled = false;
        //    ts_PagePrevious.Enabled = true;
        //    ts_PageNext.Enabled = false;
        //    SelectedIndexChanged();
        //}

        //private void bindingNavigatorMoveFirstPage_Click(object sender, EventArgs e)
        //{
        //    PageCurrent = 1;
        //    bindingNavigatorMoveFirstPage.Enabled = false;
        //    bindingNavigatorMoveLastPage.Enabled = true;
        //    ts_PagePrevious.Enabled = false;
        //    ts_PageNext.Enabled = true;
        //    SelectedIndexChanged();
        //}

        //private void ts_PagePostion_TextChanged(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        if (Convert.ToInt32(ts_PagePostion.Text) > 0 && Convert.ToInt32(ts_PagePostion.Text) <= cPages)
        //        {
        //            PageCurrent = Convert.ToInt32(ts_PagePostion.Text);
        //            if (tabControl1.TabIndex == 0)
        //            {
        //                SelectedIndexChanged();
        //            }
        //        }
        //        else
        //        {
        //            throw new Exception();
        //        }
        //    }
        //    catch (System.Exception ex)
        //    {
        //        PageCurrent = 1;
        //        SelectedIndexChanged();
        //    }
        //}
        //#endregion

        #region 获取操作题的配置分数——陈新月——2018-04-16
        DataTable dtwin = new DataTable();
        public void GetWinSore()
        {
            WinQuestionEntity winQuestion = new WinQuestionEntity();
            winQuestion.paperType = cobPaperType.Text.Trim();
            
            dtwin = WinContent.InqueryWininfo(winQuestion);
            if (dtwin.Rows.Count > 0)
            {
                //cRows = dtwin.Rows.Count;
                //cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
                //PageCurrent = 1;
                //LoadData(dtwin, dataGridView1);

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = dtwin;
                dataGridView1.AllowUserToAddRows = false;
                
                //TODO：(待完善)
                ////设定列不能自动生成
                //dataGridView1.AutoGenerateColumns = false;
                ////创建一个datagridviewLinkColumn列
                //DataGridViewLinkColumn dlink = new DataGridViewLinkColumn();
                ////添加的这列的显示文字，即每行最后一列显示的文字
                //dlink.Text = "编辑";
                //dlink.Name = "linkEdit";
                //dlink.HeaderText = "编辑";
                ////上面设置的dlink.text文字在列中显示
                //dlink.UseColumnTextForLinkValue = true;
                ////将创建的列添加到datagridview中
                //dataGridView1.Columns.Add(dlink);                        
            }

        }
        #endregion

        #region 获取Word题的配置分数——陈新月——2018-04-16
        DataTable dtword = new DataTable();
        public void GetWordSore()
        {
            WordQuestionEntity wordQuestion = new WordQuestionEntity();
            wordQuestion.PaperType = cobPaperType.Text.Trim();
            
            dtword = WordContent.InqueryWordContent(wordQuestion);
            if (dtword.Rows.Count > 0)
            {
                //cRows = dtword.Rows.Count;
                //cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
                //PageCurrent = 1;
                //LoadData(dtword, dataGridView2);

                dataGridView2.DataSource = null;
                dataGridView2.DataSource = dtword;
                dataGridView2.AllowUserToAddRows = false;
                
            }
        }
        #endregion

        #region 获取Excel题的配置分数——陈新月——2018-04-16
        DataTable dtexcel = new DataTable();
        public void GetExcelSore()
        {
            ExcelQuestionEntity excelQuestion = new ExcelQuestionEntity();
            excelQuestion.PaperType = cobPaperType.Text.Trim();
            
            dtexcel = ExcelContent.InqueryExcelInfo(excelQuestion);
            if (dtexcel.Rows.Count > 0)
            {
                //cRows = dtword.Rows.Count;
                //cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
                //PageCurrent = 1;
                //LoadData(dtexcel, dataGridView3);

                dataGridView3.DataSource = null;
                dataGridView3.DataSource = dtexcel;
                dataGridView3.AllowUserToAddRows = false;
                
            }
        }
        #endregion

        #region 获取PPT题的配置分数——陈新月——2018-04-16
        DataTable dtPPT = new DataTable();
        public void GetPPTSore()
        {
            PptQuestionEntity pptQuestion = new PptQuestionEntity();
            pptQuestion.PaperType = cobPaperType.Text.Trim();
            
            dtPPT = PPTContent.InqueryPPTInfo(pptQuestion);
            if (dtPPT.Rows.Count > 0)
            {
                //cRows = dtword.Rows.Count;
                //cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
                //PageCurrent = 1;
                //LoadData(dtPPT, dataGridView4);

                dataGridView4.DataSource = null;
                dataGridView4.DataSource = dtPPT;
                dataGridView4.AllowUserToAddRows = false;
                
            }
        }
        #endregion

        #region 获取IE题配置分数——陈新月——2018-04-16
        DataTable dtIE = new DataTable();
        public void GetIESore()
        {
            IEQuestionEntity ieQuestion = new IEQuestionEntity();
            ieQuestion.paperType = cobPaperType.Text.Trim();
            
            dtIE = IEContent.InqueryIEInfo(ieQuestion);
            if (dtIE.Rows.Count > 0)
            {
                //cRows = dtword.Rows.Count;
                //cPages = cRows % PageSize == 0 ? cRows / PageSize : cRows / PageSize + 1;
                //PageCurrent = 1;
                //LoadData(dtIE, dataGridView5);

                dataGridView5.DataSource = null;
                dataGridView5.DataSource = dtIE;
                dataGridView5.AllowUserToAddRows = false;
                
            }
        }
        #endregion

        #region 更新选择题配置-卢彦聪-2018年4月29日12:03:33
        private void UpdateSelectConfig()
        {
            ExamConfigBll selectSumConfig = new ExamConfigBll();
            SetUp enSetUp = new SetUp();
            SelectQuestionEntity enSelectQuestion = new SelectQuestionEntity();

            //选择题数量：
            int selectQuestionSum = int.Parse(numericUpDown1.Value.ToString());
            //选择题总分值：

            #region 更新选择题配置-苑仁杰-2018年12月19日10:15:33
            int selectQuestionSumFraction = int.Parse(textBox2.Text);//苑仁杰修改
            #endregion
            //每一道选择题的分值：
            double singleSelectQuestionFraction = double.Parse(((double)selectQuestionSumFraction / (double)selectQuestionSum).ToString("0.0"));

            enSetUp.selectQuestionSum = selectQuestionSum;
            enSelectQuestion.Fration = singleSelectQuestionFraction.ToString();

            //开始更新选择题考试题量,以及每一道选择题的分值
            selectSumConfig.UpdateSelectQuestionSum(enSetUp);//更新选择题个数-苑仁杰
            selectSumConfig.UpdateSelectQuestionFraction(enSelectQuestion);//更新每道选择题的分数
            ////更新选择题总分数-苑仁杰-2018-12-22
            //SelectQuestionBll selectQuestionBll = new SelectQuestionBll();
            //SelectQuestionRecordEntity selectQuestionRecordEntity = new SelectQuestionRecordEntity();

            //selectQuestionBll.UpdateSelectQuestionRecordByStudentInfo(selectQuestionRecordEntity);


        }
        #endregion

        #region 更新操作题配置的分数——陈新月——2018-04-16
        public void UpdateWinSore()
        {
            List<WinQuestionEntity> listWin = new List<WinQuestionEntity>();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                WinQuestionEntity enWinQuestion = new WinQuestionEntity();
                enWinQuestion.paperType = cobPaperType.Text.Trim();
                enWinQuestion.fraction = dataGridView1.Rows[i].Cells[0].Value.ToString();
                enWinQuestion.questionFlag = dataGridView1.Rows[i].Cells[1].Value.ToString();
                listWin.Add(enWinQuestion);
            }
            int UpdateWin = WinContent.UpdateWinInfo(listWin);

        }
        #endregion

        #region 更新Word题配置的分数——陈新月——2018-04-17
        public void UpdateWordSore()
        {
            List<WordQuestionEntity> listWord = new List<WordQuestionEntity>();
            for (int i = 0; i < dataGridView2.Rows.Count; i++)
            {
                WordQuestionEntity enWordQuestion = new WordQuestionEntity();
                enWordQuestion.PaperType = cobPaperType.Text.Trim();
                enWordQuestion.Fration = dataGridView2.Rows[i].Cells[0].Value.ToString();
                enWordQuestion.QuestionFlag = dataGridView2.Rows[i].Cells[1].Value.ToString();
                listWord.Add(enWordQuestion);
            }
            int UpdateWord = WordContent.UpdateWordInfo(listWord);

        }
        #endregion

        #region 更新Excel题配置的分数——陈新月——2018-04-17
        public void UpdateExcelSore()
        {
            List<ExcelQuestionEntity> listExcel = new List<ExcelQuestionEntity>();
            for (int i = 0; i < dataGridView3.Rows.Count; i++)
            {
                ExcelQuestionEntity enExcelQuestion = new ExcelQuestionEntity();
                enExcelQuestion.PaperType = cobPaperType.Text.Trim();
                enExcelQuestion.Fration = dataGridView3.Rows[i].Cells[0].Value.ToString();
                enExcelQuestion.QuestionFlag = dataGridView3.Rows[i].Cells[1].Value.ToString();
                listExcel.Add(enExcelQuestion);
            }
            int UpdateExcel = ExcelContent.UpdateExcelInfo(listExcel);

        }
        #endregion

        #region 更新PPT题配置的分数——陈新月——2018-04-17
        public void UpdatePPTSore()
        {
            List<PptQuestionEntity> listPPT = new List<PptQuestionEntity>();
            for (int i = 0; i < dataGridView4.Rows.Count; i++)
            {
                PptQuestionEntity enPPTQuestion = new PptQuestionEntity();
                enPPTQuestion.PaperType = cobPaperType.Text.Trim();
                enPPTQuestion.Fration = dataGridView4.Rows[i].Cells[0].Value.ToString();
                enPPTQuestion.QuestionFlag = dataGridView4.Rows[i].Cells[1].Value.ToString();
                listPPT.Add(enPPTQuestion);
            }
            int UpdatePPT = PPTContent.UpdatePPTInfo(listPPT);

        }
        #endregion

        #region 更新IE题配置的分数——陈新月——2018-04-17
        public void UpdateIESore()
        {
            List<IEQuestionEntity> listIE = new List<IEQuestionEntity>();
            for (int i = 0; i < dataGridView5.Rows.Count; i++)
            {
                IEQuestionEntity enIEQuestion = new IEQuestionEntity();
                enIEQuestion.paperType = cobPaperType.Text.Trim();
                enIEQuestion.fraction = dataGridView5.Rows[i].Cells[0].Value.ToString();
                enIEQuestion.questionFlag = dataGridView5.Rows[i].Cells[1].Value.ToString();
                listIE.Add(enIEQuestion);
            }
            int UpdateIE = IEContent.UpdateIEInfo(listIE);
        }
        #endregion

        #region 将获取到的操作题分值显示到文本框中——陈新月——2018-04-18
        public void assignWin()
        {
            float s = 0;
            //dataGridView1.DataSource = dtwin;
            for (int j = 0; j < dataGridView1.Rows.Count; j++)
            {
                if (!dataGridView1.Rows[j].IsNewRow)
                {
                    s = s + float.Parse(dataGridView1[0, j].Value.ToString());
                }
            }

            textBox3.Text = s.ToString();

        }
        #endregion

        #region 将获取到的Word题分值显示到文本框中——陈新月——2018-04-18
        public void assignWord()
        {
            
            float s = 0;            
           // dataGridView2.DataSource = dtword;         
            for (int j = 0; j < dataGridView2.Rows.Count; j++)
            {
                if (!dataGridView2.Rows[j].IsNewRow)
                {
                   s = s + float.Parse(dataGridView2[0, j].Value.ToString());
                }
            }
            
            textBox4.Text = s.ToString();
        }
        #endregion

        #region 将获取到的Excel题分值显示到文本框中——陈新月——2018-04-18
        public void assignExcel()
        {
            float s = 0;
            //dataGridView3.DataSource = dtexcel;
            for (int i = 0; i < dataGridView3.Rows.Count; i++)
            {
                if (!dataGridView3.Rows[i].IsNewRow)
                {
                    s = s + float.Parse(dataGridView3[0, i].Value.ToString());
                }
            }
            textBox5.Text = s.ToString();
        }
        #endregion

        #region 将获取到的PPT题分值显示到文本框中——陈新月——2018-04-18
        public void assignPPT()
        {
            float s = 0;
            //dataGridView4.DataSource = dtPPT;
            for (int i = 0; i < dataGridView4.Rows.Count; i++)
            {
                if (!dataGridView4.Rows[i].IsNewRow)
                {
                    s = s + float.Parse(dataGridView4[0, i].Value.ToString());
                }
            }
            textBox6.Text = s.ToString();
        }
        #endregion

        #region 将获取到的IE题分值显示到文本框中——陈新月——2018-04-18
        public void assignIE()
        {
            float s = 0;
            //dataGridView5.DataSource = dtIE;
            for (int i = 0; i < dataGridView5.Rows.Count; i++)
            {
                if (!dataGridView5.Rows[i].IsNewRow)
                {
                    s = s + float.Parse(dataGridView5[0, i].Value.ToString());
                }
            }
            textBox7.Text = s.ToString();
        }

        #endregion

        #region 当点击窗体关闭按钮时，给出提示——陈新月——2018-04-19
        private void frmAllSore_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                DialogResult r = MessageBox.Show("确定要退出程序?，未保存记录可能会消失", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (r != DialogResult.OK)
                {
                    e.Cancel = true;
                }
            }
        }


        #endregion
        
    }
}
